<template>
  <div class="rightMiddle">
    <div class="headerMaintitle">
      <img class="topPic" src="../assets/rightBottom3.png" alt="" />
      <div class="headerText">标题1</div>
    </div>
    <div class="myTable">
      <div class="myHead">
        <div class="th1">窖井</div>
        <div class="th2">流量（m³/h）</div>
        <div class="th3">水位（m）</div>
        <img src="../assets/leftBottomIcon.png" alt="" />
      </div>
      <div class="list">
        <transition-group
          leave-active-class="animate__flipOutX"
          v-if="!isEmpty"
        >
          <div class="line" v-for="item in list" :key="item.name">
            <div class="th1">{{ item.name }}</div>
            <div class="th2">{{ item.totalResult }}</div>
            <div class="th3">{{ item.hadDoneResult }}</div>
          </div>
        </transition-group>
        <div
          v-else
          style="width: 122px; height: 94px; margin: 0 auto; margin-top: 80px"
        >
          <img src="../assets/empyt.png" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "RightMiddle",
  props: {},
  components: {},
  data() {
    return {
      cList: [],
      list: [],
      index: 0,
      timer: null,
      isEmpty: false,
    };
  },
  computed: {},
  watch: {},
  methods: {
    init() {
      this.timer = setInterval(() => {
        if (this.list.length < 5 && this.cList.length > 0) {
          this.list = this.cList;
        }
        if (this.list.length >= 5) {
          this.list = this.list.slice(5);
        } else if (this.list.length == 0) {
          this.list = [];
        }
        console.log("this.list", this.list);
      }, 6000);
    },
  },
  beforeCreate() {},
  created() {
    for (let i = 1; i < 71; i++) {
      const totalResult = (Math.random() * 20 + 30).toFixed(2);
      const hadDoneResult = (Math.random() * 13 + 8.8).toFixed(2);
      this.cList.push({
        name: "窖井" + i,
        totalResult,
        hadDoneResult,
      });
    }
    this.list = this.cList;
    console.log("this.cList", this.cList);
    this.init();
  },
  beforeMount() {},
  mounted() {},
  updated() {},

  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
};
</script>
<style lang="less" scoped>
.rightMiddle {
  position: relative;
}
.myTable {
  padding: 24px 10px;
  height: 361px;
  .myHead {
    height: 52px;
    background: linear-gradient(
      180deg,
      rgba(71, 150, 217, 0.3) 0%,
      rgba(34, 93, 177, 0.3) 100%
    );
    border-bottom: 2px solid rgba(22, 124, 255, 0.3);
    display: flex;
    align-items: center;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    img {
      position: absolute;
      left: 5px;
      top: 4px;
    }
  }
  .th1 {
    flex: 1;
    text-align: left;
    padding-left: 30px;
  }
  .th2 {
    // width: 25%;
    width: 200px;
  }
  .th3 {
    width: 200px;
    // width: 25%;
  }
  .list {
    // border: 1px solid rgba(143, 179, 255, 0.2);
    // border-bottom: 0;
    height: 260px;
    overflow: scroll;
  }
  .line {
    display: flex;
    width: 704px;
    height: 52px;
    background: rgba(39, 61, 118, 0.23);
    border: 1px solid rgba(143, 179, 255, 0.2);
    border-top: 0;
    font-size: 20px;
    color: #ffffff;
    line-height: 52px;
    .th3 {
      color: rgba(1, 255, 254, 1);
    }
    .th4 {
      color: rgba(246, 224, 55, 1);
    }
  }
}
</style>
